#include <driver/motor/motor.h>
#include <driver/motor/servo_kinco.h>
#include <driver/motor/servo_zapi.h>
#include <driver/motor/servo_curtis.h>
#include <driver/motor/servo_newstart.h>
#include <driver/motor/servo_yufeng.h>
#include <driver/motor/servo_keya.h>

namespace ros_canopen_driver {
class MotorFactory
{
public:
    MotorFactory();
    ~MotorFactory();

    static std::shared_ptr<Motor> 
    generateMotor(std::shared_ptr<rclcpp::Node> node, 
        const std::string joint_name, 
        const int servo_manufacturer)
    {
        std::shared_ptr<Motor> m;
        switch (servo_manufacturer) {
            case KINCO:
                m = std::make_shared<ServoKinco>(node, joint_name);
                break;
            case ZAPI:
                m = std::make_shared<ServoZapi>(node, joint_name);
                break;
            case CURTIS:
                m = std::make_shared<ServoCurtis>(node, joint_name);
                break;
            case NEWSTART:
                m = std::make_shared<ServoNewstart>(node, joint_name);
                break;
            case YUFENG_CURTIS:
                m = std::make_shared<ServoYufengCurtis>(node, joint_name);
                break;
            case KEYA:
                m = std::make_shared<ServoKeya>(node, joint_name);
                break;
            default:
                RCLCPP_ERROR(node->get_logger(), "unknown Motor type: %d", servo_manufacturer);
                m = nullptr; 
                break;
        }
        return m; 
    };
};

}